import Vue from 'vue'
import Vuex from 'Vuex'
Vue.use(Vuex)

const user = localStorage.getItem('user');
const modules = localStorage.getItem('modules')
const saveType = localStorage.getItem('saveType')
const cut = localStorage.getItem('cut');
const curMsg = localStorage.getItem('curMsg');
const store = new Vuex.Store({
    state: {
        user: JSON.parse(user),
        modules:JSON.parse(modules),
        saveType:saveType,
        cut: JSON.parse(cut),
        openTimes:100,
        showType:1,
        curMsg:JSON.parse(curMsg)
    },
    mutations: {
        currentMsg(state,curMsg){
            state.opencurMsgTimes = curMsg
            localStorage.setItem('curMsg', curMsg)
        },
        openTime(state,openTimes){
            state.openTimes = openTimes
            localStorage.setItem('openTimes', openTimes)
        },
        chaneShow(state,showType){
            state.showType = showType
        },
        getUser(state, userMsg) {
            state.user = JSON.parse(userMsg)
            localStorage.setItem('user', userMsg)
        },
        getModule(state,moduleMsg){
            state.modules = JSON.parse(moduleMsg)
            localStorage.setItem('modules',moduleMsg)
        },
        saveType(state,saveTypeMsg){
            state.saveType = saveTypeMsg
            localStorage.setItem('saveType',saveTypeMsg)
        },
        getCut(state, cut) {
            state.cut = JSON.parse(cut)
            localStorage.setItem('cut', cut)
        },
    }
})
export default store